package com.springboot.cloud.demos.ribbon.rest;

import com.springboot.cloud.common.core.entity.vo.Result;
import com.springboot.cloud.demos.entity.form.LessonForm;
import com.springboot.cloud.demos.entity.form.QuestionForm;
import com.springboot.cloud.demos.ribbon.service.AnswerService;
import com.springboot.cloud.demos.ribbon.service.LessonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class LessonController {

    @Autowired
    private LessonService lessonService;

    @GetMapping("/lesson")
    public Result query(@RequestParam("unitId") String unitId) {
        return lessonService.query(unitId);
    }

    @GetMapping("/lesson/{id}")
    public Result get(@PathVariable(value = "id") String id) {
        return lessonService.get(id);
    }

    @PostMapping("/lesson")
    public Result add(@RequestBody LessonForm lessonForm) {
        return lessonService.save(lessonForm);
    }

    @PutMapping(value = "/lesson")
    public Result update(@RequestBody LessonForm lessonForm) {
        return lessonService.update(lessonForm);
    }
}
